window.mofang.moniter.taskBill = function() {

	var params = {data:{page : 1, pageSize : 50}, url : 'monitor/Task/obtainTaskBill.koala'};
	
	var init = function() {
				
		// 任务显示init
		_grid.init();
		pageTool.init();
		requestData();
	};
	
	var pageTool = page({
		renderTo : "task_bill_Page",
		pageSize : params.data.pageSize,
		subHandler : function(data) {
			params.data.page = data.currNo;
			params.data.pageSize = data.pageSize;
			requestData();
		}
	});
	
	var _grid = grid({
		renderTo 	: 'task_bill_grid', 
		columns  : [	{name : '渠道名称', dataIndex : 'channelName'},
		             	{name : '任务总数', dataIndex : 'taskTotal'},
		             	{name : '成功次数', dataIndex : 'taskSuccess'},
		             	{name : '失败次数', dataIndex : 'taskException'},
		             	{name : '成功率', funHandler: function(data){
			             		var rates = data.successRates;
			             		if(rates >= 90){
			             			return '<font color="green">' + data.successRates + '%</font>';
			             		} else if(rates < 70){
			             			return '<font color="red">' + data.successRates + '%</font>';
			             		} else {
			             			return '<font color="blue">' + data.successRates + '%</font>';	
			             		}
		             		}
		             	},
		             	{name : '执行中', dataIndex : 'taskDoing'}
		           ]
	});
	
	var requestData = function() {
		
		util.mofangAjax({
			url       : params.url,
			data      : params.data ,
			succFun   : function(json) {
				_grid.addDatas({
					rowDatas : json.data
				});
				pageTool.render(json.resultCount, params.data.page);
			}

		});
	};

	return {
		init : init
	};
};